home *** CD-ROM | disk | FTP | other *** search
- # MIDIOX Test -- Python Script
- # Copyright (c) 2000 by Jamie O'Connell
- #
- # This script is an example of using MIDI-OX scripting with Python
-
- global mox
-
- # Wsh version
- moxStr = WScript.Name + " ver. " + WScript.Version
- WScript.echo( moxStr )
-
- # Create object
- mox = WScript.CreateObject("MoxKart.MoxWire.1")
-
- moxStr = "MIDI-OX"
- n = mox.NumberInstances
- if n > 0:
- moxStr = moxStr + ":" + str( n )
- else:
- WScript.echo( "No Instances, Launching" )
- mox.LaunchInstance()
-
- moxStr = moxStr + " Ver:"
- moxStr = moxStr + mox.GetAppVersion()
-
- WScript.echo( moxStr )
-
- n = mox.NumberInstances
- if n > 0:
- nInst = 1
- if mox.AttachInstance( nInst ) == 1:
- moxStr = "Attached Instance: %d" % nInst
- WScript.echo( moxStr )
- else:
- moxStr = "Couldn't Attach Instance: %d" % nInst
- WScript.echo( moxStr )
-
-
- # *** System devices
- moxStr = "Sys MIDI In Devices: %d" % mox.NumSysMidiIn
- strWrk = mox.GetFirstSysMidiInDev()
- while strWrk != "":
- moxStr = moxStr + "\n " + strWrk
- strWrk = mox.GetNextSysMidiInDev()
-
- WScript.echo( moxStr )
-
- moxStr = "Sys MIDI Out Devices: %d" % mox.NumSysMidiIn
- strWrk = mox.GetFirstSysMidiOutDev()
- while strWrk != "":
- moxStr = moxStr + "\n " + strWrk
- strWrk = mox.GetNextSysMidiOutDev()
-
- WScript.echo( moxStr )
-
- # *** MIDI-OX devices
- if mox.IsAttached == 1:
- moxStr = "Open MIDI In Devices: %d" % mox.NumOpenMidiIn
- strWrk = mox.GetFirstOpenMidiInDev()
- while strWrk <> "":
- moxStr = moxStr + "\n " + strWrk
- strWrk = mox.GetNextOpenMidiInDev()
- WScript.echo( moxStr )
-
- if mox.IsAttached == 1:
- moxStr = "Open MIDI Out Devices: %d" % mox.NumOpenMidiOut
- strWrk = mox.GetFirstOpenMidiOutDev()
- while strWrk <> "":
- moxStr = moxStr + "\n " + strWrk
- strWrk = mox.GetNextOpenMidiOutDev()
- WScript.echo( moxStr )
-
- if mox.IsAttached == 1:
- mox.DivertMidiInput = 1
- mox.FireMidiInput = 0
- WScript.echo( "Press OK to enter MIDI Loop. Use MIDI-OX | Exit WScript to end." )
- while mox.ShouldExitScript == 0:
- # First try raw Input
- msg = mox.GetMidiInputRaw()
- if msg != 0:
- stat = msg & 0x0FF
- msg = msg >> 8 # pull off stat
- dat1 = msg & 0x07F
- msg = msg >> 8 # pull off dat1
- dat2 = msg & 0x07F
- if stat == 0x0F0: # SysEx, must ask for SysEx string message
- strSysEx = mox.GetSysExInput()
- mox.SendSysExString( strSysEx )
- else:
- mox.OutputMidiMsg( stat, dat1, dat2 )
-
- mox.DivertMidiInput = 0
-
- WScript.echo( "End Demo" )
-